/**
 * meituan.com Inc.
 * Copyright (c) 2010-2023 All Rights Reserved.
 */
package com.recruit.common.util;

import lombok.extern.slf4j.Slf4j;

import java.util.Random;

/**
 * <p>
 *
 * </p>
 *
 * @author denghufu
 * @version RandUtil.java v1.0 2023/2/27 19:54 denghufu Exp $
 */
@Slf4j
public class RandUtil {

    public static final Integer CODE_LENGTH = 6;

    public static String getRandNum() {
        String randNum = new Random().nextInt(1000000) + "";
        log.info("手机验证码={}", randNum);
        //如果生成的不是6位数随机数则返回该方法继续生成
        if (randNum.length() != CODE_LENGTH) {
            return getRandNum();
        }
        return randNum;
    }

}
